package com.example.ivory.accountbook.Activity;

import android.content.Intent;
import android.icu.text.SimpleDateFormat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.ivory.accountbook.R;
import com.example.ivory.accountbook.fragment.Fragment_details;

public class Test extends AppCompatActivity {

    private CalendarView calendarView;
    private Button buttonBack;
    private Button buttonAdd;
    private TextView textView;


    @Override
    protected void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        calendarView=(CalendarView)findViewById(R.id.calendarView);
        buttonBack=(Button)findViewById(R.id.back);
        buttonAdd=(Button)findViewById(R.id.add);
        textView=(TextView)findViewById(R.id.date);
        long l=calendarView.getDate();
        SimpleDateFormat f=new SimpleDateFormat("yyyy年M月d日");
        String time=f.format(l);
        textView.setText(time);
        calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
            @Override
            public void onSelectedDayChange(CalendarView calendarView, int i, int i1, int i2) {
                String da = i + "年" +( i1+1) + "月" + i2 + "日";
               // Toast.makeText(getApplicationContext(), date, 0).show();
                textView.setText(da);
            }
        });
        buttonAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(Test.this,AddItem.class);
                startActivity(intent);
            }
        });
        buttonBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Test.this, Activity_main.class);
                startActivity(intent);
            }
        });
    }
}
